package com.tinytoon.hunghoaqua;

import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
/*
 * get, update, remove records in database
 * */
public class DatabaseUtil {
	private SQLiteDatabase db;

	public DatabaseUtil(Context context) {
		SQLiteHelper helper = new SQLiteHelper(context);//database created this step
		db = helper.getWritableDatabase();
	}
	
	public void removeRecord(int id){
		db.delete("playerscore", "_id"+"="+id,null);
	}
	public void addRecord(Integer score, String name){
		ContentValues content = new ContentValues();
		content.put("score", score);
		content.put("name", name);
		db.insert("playerscore", null, content);
	}
	public Cursor getRecords() {
		return db.rawQuery("select * from playerscore order by score desc", null);		
	}
}
